<!DOCTYPE html>
<html>
<head>
	<title>节流</title>
</head>
<body>
	<button onclick="btn()">节流</button>
</body>
<script type="text/javascript">
	
	const btn = (function(time) {
		let lastTime = Date.now();
		return function() {
			let nowTime = Date.now();
			if(nowTime - lastTime >= time) {
				console.log(`${time}ms触发一次`);
				lastTime = nowTime;
			}
		}
	})(1000);

</script>
</html>